<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div id="statistics">
    <%--<ol>--%>
    <br/>
    <h4>Statistics for selected questionnaire are:</h4>
    <table id="statistics_table">
        <c:forEach items="${responseQStatistics}" var="responseQSt">
            <%--<li>--%>
            <tr>
                <td class="question_row" colspan="2">${responseQSt.question.text}</td>
            </tr>
            <c:forEach items="${responseQSt.responsePercentage}" var="responsePercentage">
                <tr class="${responsePercentage.percentage}">
                    <td>${responsePercentage.response.text}</td>
                    <td class="responsePercentage">
                        <span>
                            <fmt:formatNumber maxFractionDigits="2" value="${responsePercentage.percentage}"/>%
                        </span>
                    </td>
                </tr>
            </c:forEach>
            <%--</li>--%>
        </c:forEach>
    </table>
    <%--</ol>--%>
</div>

<script type="text/javascript">
    jQuery(document).ready(function ($) {
        $("#statistics ol li").each(function () {
            var max = 0.0;
            var value;
            var elem;
            $(this).find(".responsePercentage").each(function () {
                value = parseFloat($(this).find("span").html());
                if (value > max) {
                    max = value;
                    elem = $(this);
                }
            });
            elem.addClass("emphasize");
        });
    });
</script>
